<template>
  <FormView
    v-model="entity"
    :title="entity.id ? '修改条码库' : '新建条码库'"
    :toolbar-attrs="{ buttons: ['back', 'save', 'cancel'] }"
    :toolbar-listeners="{ save: persist }">
    <FormHolder ref="form" label-width="110px" :model="entity">
      <FormItemGroup block-title="基本信息">
        <FormInput v-model="entity.barcode" prop="barcode" label="条形码" max-length="100" required />
        <FormInput v-model="entity.name" prop="name" label="名称" max-length="255" required />
        <FormInput v-model="entity.place" prop="place" :span="24" label="地址" max-length="255" required />
        <FormInput v-model="entity.unit" prop="unit" label="计量单位" max-length="255" required />
        <FormInput v-model="entity.standard" prop="standard" label="规格型号" max-length="255" required />
        <FormInputNumber v-model="entity.price" prop="price" label="价格" />
        <FormInput v-model="entity.supplier" prop="supplier" label="供应商" max-length="255" />
        <FormInput v-model="entity.brand" prop="brand" label="品牌" max-length="255" />
        <FormInput v-model="entity.country" prop="country" label="国家" max-length="255" />
      </FormItemGroup>
    </FormHolder>
  </FormView>
</template>

<script>
  import { addObj, putObj, getObj } from '@/api/asset/fyassetpublicbarcode'
  import form from '@/vue/mixin/form'

  export default {
    name: 'PublicbarcodeForm',
    relativeViewId: 'PublicbarcodeView',
    mixins: [form],
    data() {
      return {
        entity: {
          barcode: '',
          brand: '',
          country: '',
          id: '',
          name: '',
          place: '',
          price: null,
          standard: '',
          supplier: '',
          unit: ''
        }
      }
    },
    created() {
      this.init()
    },
    methods: {
      load: getObj,
      save: addObj,
      update: putObj,
      async init() {}
    }
  }
</script>
